<!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>用户中心页面</title>
    </head>
    <body>
    <form action="headIMG.php" method="post" enctype="multipart/form-data">
        上传头像：<input type="file" name="headIMG" id="headIMG" value="" onchange="showIMG()" />
        <br/>
        <input type="submit" value="提交">
        <img src="" id="imgid">
    </form>
    </body>
    <script type="text/javascript">
        function showIMG(){
            var fileObj = document.getElementById('headIMG');
            var URL = window.URL || window.webkitURL;
            var imgURL = URL.createObjectURL(fileObj.files[0]);
            document.getElementById('imgid').src=imgURL;
        }
    </script>
</html>
<?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    if(!empty($username) && !empty($password)){
        echo '登入成功';
        echo '<br/>';
        $token = md5($username.$password);
        if ($username == 'admin' && $password == '888888'){
            setcookie('Token',$token,time()+3600*24);
        }else{
            echo '用户名或密码错误';
        }
        if (isset($_COOKIE['Token'])){
            echo '存在COOKIE';
        }else{
            echo '不存在COOKIE';
        }
    }else{
        echo '没有输入用户名和密码';
    }


